﻿@*
    For more information on enabling MVC for empty projects, visit https://go.microsoft.com/fwlink/?LinkID=397860
*@
@{
    Layout = null;
}

<link href="~/lib/layui/css/layui.css" rel="stylesheet" />
<script src="~/lib/layui/layui.js"></script>
<script src="~/js/js.cookie.js"></script>
<script src="~/js/moment.js"></script>
<script src="~/lib/jquery/dist/jquery.js"></script>

<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>部门列表</title>
</head>
<body class="layui-padding-3">
    <table class="layui-table" height: 315>
        <colgroup>
            <col width="150">
            <col width="150">
            <col width="150">
            <col width="150">
            <col width="150">
        </colgroup>
        <thead>
            <tr>
                <th>部门编号</th>
                <th>企业全称</th>
                <th>部门名称</th>
                <th>部门类型</th>
                <th>区域</th>
            </tr>
        </thead>


        <tbody id="thisTd">
        </tbody>
    </table>
    <div id="demo-laypage-all"></div>
    <script>

        layui.use(function () {
            var form = layui.form;
            var laypage = layui.laypage;
            var layer = layui.layer;
            var util = layui.util;

            $(function () {
                getPerList(pageIndex, pageSize);
            })
            var pageIndex = 1;
            var pageSize = 2;
            function getPerList(index, size) {
                $.ajax({
                    url: '@ViewBag.FoundationWrite' + "/api/Jocker/Departmentslist",
                    type: "POST",
                    data: JSON.stringify({ pageIndex: index, pageSize: size }),
                    contentType: "application/json",
                    success: function (res) {
                        console.log(index, size);

                        console.log(res.pageCount);
                        $("#thisTd").empty();
                        $(res.data).each(function () {
                            $("#thisTd").append(`<tr>
                            <td>${this.departmentNo}</td>
                            <td>${this.levelName}</td>
                            <td>${this.departmentName}</td>
                            <td>${this.typeName}</td>
                            <td>${this.areaName}</td></tr>`)
                        })
                        var laypage = layui.laypage;
                        // 完整显示
                        laypage.render({
                            elem: 'demo-laypage-all', // 元素 id
                            count: res.totalCount, // 数据总数
                            limit: size, // 每页显示的条数
                            curr: index, // 当前页
                            limits: [2, 3, 4],
                            layout: ['count', 'prev', 'page', 'next', 'limit', 'refresh', 'skip'], // 功能布局
                            jump: function (obj, first) {
                                // 首次不执行
                                // 首次不执行
                                if (!first) {
                                    console.log(obj.curr);
                                    console.log(obj.limit);
                                    getPerList(obj.curr, obj.limit);
                                }


                            }
                        });
                    }
                })

            }


        });
    </script>
</body>
</html>
